package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.LiveBanner;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.LiveBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/26 14:25
 */
@Api(tags = "直播轮播图")
@CrossOrigin
@RestController
@RequestMapping("/liveBanner")
public class LiveBannerController {

    @Autowired
    private LiveBannerService liveBannerService;

    @ApiOperation("添加轮播图 liveTypeId  0 是主页的  -1 是 直播页面的  轮播图")
    @PostMapping("/add")
    public R<Void> add(LiveBanner liveBanner) {
        return liveBannerService.add(liveBanner);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return liveBannerService.delete(id);
    }

    @ApiOperation("根据Id更新  若id为0  就是修改直播背景图片")
    @PostMapping("/update")
    public R<Void> update(LiveBanner liveBanner) {
        return liveBannerService.update(liveBanner);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<LiveBanner>> page(@RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size) {
        return liveBannerService.page(page, size);
    }

    @ApiOperation("根据liveTypeId获取直播轮播图  注意  0 是主页的  -1 是 直播页面的")
    @GetMapping("/getLiveBanner")
    public R<List<LiveBanner>> getLiveBanner(Integer liveTypeId) {
        return liveBannerService.getLiveBanner(liveTypeId);
    }

}
